<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../common.inc" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var functionName = document.getElementById("functionName");
		var parentId = document.getElementById("parentId");
		var functionOrder = document.getElementById("functionOrder");
		var url = document.getElementById("url");
		
		if(functionName.value == ""){
			alert("<fmt:message key='func.lable.funcName'/><fmt:message key='common.message.empty'/>");
			return false;
		}
		
		if(parentId.value == -1){
			alert("<fmt:message key='func.message.parent'/>");
			return false;
		}
		
		if(functionOrder.value == ""){
			alert("<fmt:message key='func.lable.funcOrder'/><fmt:message key='common.message.empty'/>");
			return false;
		}
		return true;
	}

	function back(){
		window.location.href = "./functionTree.do";
		window.location.target = "main";
	}
	
	function addSaleRecord(){
		window.location.href = "addSaleRecord.html";
		window.location.target = "main";
	}
	
	function updateSaleRecord(){
		window.location.href = "updateRecord.html";
		window.location.target = "main";
	}
	
	function updateAction(){
		var url = "updateAction.html";
		var dlgParam = "dialogHeight:150px;dialogWidth:280px;dialogTop:300px;dialogLeft:400px;status:no;help:no;scrollbars:no;";
		window.showModalDialog(url,"",dlgParam);
	}
	
	function update(){
		if(checkForm()){
			document.updateFunctionForm.action = "./functionTree.do?action=updateFunction";
			document.updateFunctionForm.target = "main";
			document.updateFunctionForm.submit();
		}
	}
	
	function initPage(result,repeat){
		if(result == 1){
			alert("<fmt:message key='common.message.updateSuccess'/>");
		}
		if(repeat == 1){
			alert("<fmt:message key='common.message.updateFail'/><fmt:message key='func.lable.funcName'/><fmt:message key='common.message.exist'/>");
		}
	}
-->
</script>
</head>
<body onload="initPage('${result}','${repeat}')">
<form name="updateFunctionForm" action="" method="post">
	<table class="table_frame" cellpadding="0" cellspacing="0">
		<tr>
			<td>
				<table class="table_title" cellpadding="0" cellspacing="0">
					<tr>
						<td class="title_lab" colspan="3">
							&nbsp;&nbsp;&nbsp;&nbsp;<fmt:message key='func.title.update'/>
						</td>
					</tr>
					<tr><td height="15"></td></tr>
					<tr>
						<td valign="bottom">&nbsp;
							<a href="javascript:update();" title="<fmt:message key='common.button.save'/>" hidefocus="true"><fmt:message key='common.button.save'/></a>
						</td>
						<td valign="bottom" align="right">
							<a href="javascript:back();" title="<fmt:message key='common.button.back'/>" hidefocus="true"><fmt:message key='common.button.back'/></a>&nbsp;&nbsp;&nbsp;&nbsp;
						</td>
					</tr>
					<tr><td height="2"></td></tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="5"></td>
		</tr>
		<tr>
			<td>
				<table class="table1" cellpadding="0" cellspacing="0">
					<tr>
						<td>
							<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 100px;">
								<tr><td class="title3" colspan="2"></td></tr>
								<tr>
									<td class="" width="15%"><fmt:message key='func.lable.funcName'/><fmt:message key='common.sign'/><input id="id" name="id" type="hidden" value="${function.id}"/></td>
									<td class=""><input id="functionName" name="functionName" class="input_long" type="text" value="${function.functionName}"/></td>
								</tr>
								<tr>
									<td class="" width="15%"><fmt:message key='func.lable.funcNameEn'/><fmt:message key='common.sign'/></td>
									<td class=""><input id="functionNameEn" name="functionNameEn" class="input_long" type="text" value="${function.functionNameEn}"/></td>
								</tr>
								<tr>
									<td class="" width=""><fmt:message key='func.lable.parent'/><fmt:message key='common.sign'/></td>
									<td class="">
										<select id="parentId" name="parentId">
											<option value="0" <c:if test='${function.parentId == 0}'>selected</c:if> >
												-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											</option>
											<c:forEach var="sfunction" items="${functions}">
												<c:if test="${sfunction.parentId == 0}">
												<option value="${sfunction.id}" <c:if test='${sfunction.id == function.parentId}'>selected</c:if> >
													${sfunction.functionName}
												</option>
												</c:if>
											</c:forEach>
										</select>
									</td>
								</tr>
								<tr>
									<td class="title3" width=""><fmt:message key='func.lable.funcOrder'/><fmt:message key='common.sign'/></td>
									<td class="title3" width="">
										<input id="functionOrder" name="functionOrder" class="input_long" type="text" value="${function.functionOrder}"/>
									</td>
								</tr>
								<tr>
									<td class="title3" width="">URL：</td>
									<td class="title3" width="">
										<input id="url" name="url" class="input_long" type="text" value="${function.url}"/>
									</td>
								</tr>
								<tr>
									<td class="title3" width=""><fmt:message key='common.lable.isActivity'/><fmt:message key='common.sign'/></td>
									<td class="title3" width="">
										<input name="isActivity" type="radio" <c:if test='${function.isActivity == 1}'>checked</c:if> hidefocus="true" value="1"/><fmt:message key='common.lable.is'/>&nbsp;&nbsp;
										<input name="isActivity" type="radio" <c:if test='${function.isActivity == 0}'>checked</c:if> hidefocus="true" value="0"/><fmt:message key='common.lable.no'/>
									</td>
								</tr>
								<tr><td class="title3" colspan="2"></td></tr>
							</table>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</form>
</body>
</html>